<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>查询页面</title>
    <link rel="stylesheet" href="/static/style.css">
</head>
<body>
    <div class="sidebar">
        <ul>
            <li><a href="/main">主页</a></li>
            <li><a href="/action">行为</a></li>
            <li><a href="/realtime">实时数据</a></li>
            <li><a href="/logout" class="logout">登出</a></li>
        </ul>
    </div>
    <div class="content">
    <h1>查询传感器信息</h1>
 
    <!-- 查询表单 -->
    <form action="/query" method="post">
        <input type="text" name="sensor_id" placeholder="请输入传感器编号" required>
        <button type="submit">查询</button>
    </form>

    {% if sensor_id %}
    <h2>传感器信息</h2>
    <p>传感器 ID: {{ sensor_id }}</p>
    <p>类型: {{ sensor_type }}</p>
    <p>位置: {{ location }}</p>
    <p>状态: {{ status }}</p>

    <h3>最新数据</h3>
    <p>数据: {{ latest_content }}</p>
    <p>时间: {{ latest_time }}</p>

    <h3>历史数据</h3>
    <ul>
        {% for content, time in history_data %}
            <li>数据: {{ content }} | 时间: {{ time }}</li>
        {% endfor %}
    </ul>
    {% endif %}

    {% if error %}
        <p class="error">{{ error }}</p>
    {% endif %}
</body>
</html>
